package com;

import java.util.ArrayList;
import java.util.Scanner;

public class KTV {
    public static void main(String[] args) {
        ArrayList<String> songList = new ArrayList<>();
        songList.add("孤独的船");
        songList.add("不浪漫罪名");
        songList.add("吴哥窟");
        songList.add("一场游戏一场梦");
        songList.add("谁明浪子心");
        songList.add("千千阙歌");

        Scanner scanner = new Scanner(System.in);

        System.out.println("----欢迎来到点歌系统----");
        System.out.println("1.添加歌曲至列表");
        System.out.println("2.将歌曲置顶");
        System.out.println("3.将歌曲前移一位");
        System.out.println("4.退出");
        System.out.println("5.查看歌曲列表");
        System.out.println("6.删除歌曲信息");

        while (true) {
            System.out.print("请输入指令: ");
            int instruction = scanner.nextInt();

            if (instruction == 4) {
                break;
            }

            switch (instruction) {
                case 1:
                    System.out.print("请输入要添加的歌曲名: ");
                    String newSong = scanner.next();
                    songList.add(newSong);
                    System.out.println("当前歌曲列表: " + songList);
                    break;
                case 2:
                    System.out.print("请输入要置顶的歌曲名: ");
                    String topSong = scanner.next();
                    int index = songList.indexOf(topSong);
                    if (index!= -1) {
                        songList.remove(index);
                        songList.add(0, topSong);
                    }
                    System.out.println("当前歌曲列表: " + songList);
                    break;
                case 3:
                    System.out.print("请输入要前移一位的歌曲名: ");
                    String moveSong = scanner.next();
                    int moveIndex = songList.indexOf(moveSong);
                    if (moveIndex > 0) {
                        songList.set(moveIndex - 1, songList.get(moveIndex));
                        songList.set(moveIndex, moveSong);
                    }
                    System.out.println("当前歌曲列表: " + songList);
                    break;
                case 5:
                    System.out.println("当前歌曲列表: " + songList);
                    break;
                case 6:
                    System.out.print("请输入要删除的歌曲名: ");
                    String deleteSong = scanner.next();
                    songList.remove(deleteSong);
                    System.out.println("当前歌曲列表: " + songList);
                    break;
            }
        }
        scanner.close();
    }
}